<template>
  <div id="pro-file">
    <nav-bar class="pro-nav">
      <div slot="center">FangMall</div>
      <div slot="right" class="login">
          <router-link to="/login">
            <img src="~assets/img/log.png">
          </router-link>
          
      </div>
      
      
    </nav-bar>
    <div class="usermess">
      <div class="touxiang">
        <div class="left">
          <img src="~assets/img/girl.png" alt="">
        </div>
        <div class="right">
          <!-- <span v-show="!islogin">请登录账号</span> -->
          <h2>{{$store.state.usr.usrname}}</h2>
          <span class="num-name">账号: {{$store.state.usr.usrnum}}</span><br>
          <span class="guanzhu">关注&nbsp;0 | 粉丝&nbsp;0</span>
        </div>

      </div>
      <div class="order">
        <div class="header">
          <div class="head-left">
            <h2>我的订单</h2>
          </div>
          <router-link to='/order'>
            <div class="head-right">
               全部 >
            </div>
          </router-link>
          
        </div>
        <div class="order-item">
          <ul>
            <li>
              <img src="~assets/img/profile/order/fukuan.png" alt="">
              <span>待付款</span>
            </li>
            <li>
              <img src="~assets/img/profile/order/fahuo.png" alt="">
              <span>待发货</span>
              <span class="exo" :class="{ex:this.$store.state.orderList.length != 0}">{{this.$store.state.orderList.length}}</span>
            </li>
            <li>
              <img src="~assets/img/profile/order/shouhuo.png" alt="">
              <span>待收货</span>
            </li>
            <li>
              <img src="~assets/img/profile/order/pingjia.png" alt="">
              <span>待评价</span>
            </li>
            <li>
              <img src="~assets/img/profile/order/backmoney.png" alt="">
              <span>退款/售后</span>
            </li>
          </ul>
        </div>
        <div class="ord-mess">
          <div class="mess-left">
            <img src="~assets/img/profile/shopping.svg" alt="">
          </div>
          <div class="mess-right">

          </div>
        </div>
      </div>
      <div class="choose-card">

      </div>
      <div class="exit">
        <span @click="exitClick">退出登录</span>
      </div>
    </div>
  </div>
</template>

<script>
import NavBar from 'components/common/navbar/NavBar.vue';

export default {
    name: 'Profile',
    components: {
      NavBar,

    },
    data() {
      return {
        noUsrInfo: {
          usrname: '请登录账号',
          usrnum: ' ',
        },
        // islogin: this.$store.state.islogin
      }
    },
    created() {
      // this.checkLogin()
      console.log(window.localStorage.getItem('usrInfo'))
      if(this.$store.state.usr.usrname != undefined) {
        // console.log(123)
        this.$store.commit('loginchecked',true)
      }
      console.log(this.$store.state.usr)
      console.log(this.$store.state.islogin)
    },
    watch:{
		  '$store.state.usr'(){
			  //对数据执行操作
			  // console.log()

		  }
	  },

    methods: {
      //退出登录
      exitClick() {
        if(this.$store.state.usr.usrname == '请登录账号'|| this.$store.state.usr.usrname == undefined) {
          this.$toast.show('当前暂未登录账号',1000)
        }else {
          // this.$store.commit('addusrInfo',this.noUsrInfo)
          // console.log(this.$store.state.usrInfo)
          //退出提交空对象
          this.$store.commit('setusrInfo', '')
          // this.islogin = false
          console.log(this.$store.state.usr.usrname)
          this.$store.commit('loginchecked',false)
          this.$store.commit('deleteorder', [])
          this.$toast.show('已退出当前账号',1000)
        }
        
      },
      //根据usrname判断是否显示登录div
      // checkLogin() {
      //   if(this.$store.state.usr.usrname == '') {
      //     // this.islogin = false
      //   }else true
      // }
    },
}
</script>

<style scoped>
  #pro-file {
    height: 860px;
  }
  .pro-nav {
    background-color: lightblue;
    color: #fff;
  }
  .login {
    margin-top: 8px;
  }
  .login img{
    width: 30px;
    height: 30px;
  }
  .usermess {
    width: 100%;
    /* height: 100vh; */
    background-color: #f8f8f8;
    overflow: hidden;
  }
  .touxiang {
    margin: 10px auto 0;
    background-color: #fff;
    width: 360px;
    height: 130px;
    border-radius: 8px;
    background-image: url("~assets/img/preview.jpg");
  }
  .touxiang .left {
    float: left;
    padding-top: 28px;
    padding-left: 25px;
  }
  .touxiang .right {
    float: left;
    padding-top: 25px;
    margin-left: 15px;
  }
  /* .touxiang .right .active {
    display: none;
  } */
  .right h2 {
    color: #fff;
    font-size: 18px;
    line-height: 2;
  }
  .right .num-name {
    font-size: 12px;
    color: #ccc;
    line-height: 18px;
  }
  .right .guanzhu {
    font-size: 12px;
    color: #fff;
  }
  .touxiang .left img {
    width: 70px;
    height: 70px;
    
  }
  .order {
    /* overflow: hidden; */
    margin: 15px auto 0;
    width: 360px;
    height: 200px;
    border-radius: 8px;
    background-color: #fff;
  }
  .header {
    overflow: hidden;
  }
  .order {
    overflow: hidden;
  }
  .order .head-left {
    padding-left: 10px;
    line-height: 2;
    font-size: 12px;
    float: left;
  }
  .order .head-right {
    float: right;
    line-height: 2;
    padding-right: 10px;
    padding-top: 5px;
    color: #ccc;
  }
  .order-item {
    /* position: relative; */
    background-color: #fff;
    margin: 12px auto 0;
    height: 60px;
    width: 340px;
    /* background-color: green; */
    /* padding-left: 5px; */
  }
  .order-item img {
    position: relative;
    left: 19px;
    width: 30px;
    height: 30px;
    display: block;
  }
  .order-item li{
    /* margin: 0 auto; */
    position: relative;
    list-style: none;
    height: 50px;
    width: 20%;
    font-size: 12px;
    line-height: 30px;
    text-align: center;
    float: left;
    /* margin-left: 15px; */
    
  }
  .order-item li .exo{
    display: none;
  }
  .order-item li .ex{
    position: absolute;
    top: -5px;
    right: 8px;
    padding-top: 2px;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 50%;
    background-color: red;
    color: #fff;
    display: block;
  }
  .ord-mess {
    margin: 20px auto 0;
    box-shadow: 1px 1px 2px #ccc;
    width: 80%;
    height: 50px;
    background-color: rgb(243, 243, 243);
  }
  .mess-left img{
    background-color: #fff;
    width: 50px;
    height: 50px;
  }
  .choose-card {
    margin: 15px auto 0;
    width: 360px;
    height: 330px;
    border-radius: 8px;
    background-color: #fff;
  }
  .exit {
    margin: 10px auto 0;
    width: 360px;
    height: 50px;
    border-radius: 8px;
    background-color: #fff;
    font-size: 20px;
    font-weight:bolder;
    line-height: 50px;
    text-align: center;
  }
</style>
